package com.muse.designpatterns.command;

public class RemoteController {
    private Command[] OnCommand;
    private Command[] OffCommand;

    public RemoteController() {
        OnCommand = new Command[10];
        OffCommand = new Command[10];

        //默认这些按钮都是无操作的按钮
        for (int i = 0; i < OnCommand.length; i++) {
            OnCommand[i] = new NoCommand();
            OffCommand[i] = new NoCommand();
        }
    }
    //添加指令
    public void addCommand(int slot,Command onCommand,Command offCommand) {

        OnCommand[slot] = onCommand;
        OffCommand[slot] = offCommand;
    }
    //按遥控器的某个开启键
    public void pushOnButton(int slot) {
        OnCommand[slot].execute();
    }
    //按遥控器的某个关闭键
    public void pushOffButton(int slot) {
        OffCommand[slot].execute();
    }
}
